<?php
/**
 * Created by PhpStorm.
 * User: shaowei
 * Date: 2018/12/20
 * Time: 下午8:46
 */

namespace App\Http\Controllers;

use App\Http\Services\TeenagerServices;
use Illuminate\Http\Request;
use App\Lib\Response;

class TeenagerController extends BaseController
{
    protected $requestInstance;// 请求类实例
    protected $serviceTeenager;

    public function __construct()
    {
        $this->requestInstance = new Request();
        $this->serviceTeenager = new TeenagerServices();
    }

    //解锁/开锁
    public function unlocking(){
        do {
            if (!$this->checkRequest()) {
                break;
            }

            $this->callCommon($this->serviceTeenager, 'unlocking', $this->requestData);

        } while (false);

        if(is_string($this->responseData)) $this->responseData = json_decode($this->responseData, true);
        Response::returnResult($this->responseData['code'], $this->responseData['data'], $this->responseData['msg']);
    }

    //设置密码
    public function setLock(){
        do {
            if (!$this->checkRequest()) {
                break;
            }

            $this->callCommon($this->serviceTeenager, 'setLock', $this->requestData);

        } while (false);

        if(is_string($this->responseData)) $this->responseData = json_decode($this->responseData, true);
        Response::returnResult($this->responseData['code'], $this->responseData['data'], $this->responseData['msg']);
    }
}